package com.one.blocks.rbac.manager;

import com.one.blocks.mvc.manager.AbstractBatchManager;
import com.one.blocks.rbac.controller.valid.AllocatedDataValidateManager;
import com.one.blocks.rbac.domain.SysRoleMenu;
import com.one.blocks.rbac.mapper.SysRoleMenuMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Set;

/**
 * @author <a href="mailto:idler41@163.con">idler41</a> created on 2022-05-01 10:06:14
 */
@Service
public class SysRoleMenuManager extends AbstractBatchManager<SysRoleMenuMapper, SysRoleMenu> implements AllocatedDataValidateManager<Integer> {

    @Autowired
    public SysRoleMenuManager(SysRoleMenuMapper mapper) {
        super(mapper);
    }

    @Transactional(rollbackFor = Exception.class)
    public void deleteByRoleId(Integer roleId) {
        mapper.deleteByRoleId(roleId);
    }

    public Set<Integer> selectRoleId(Integer menuId) {
        return mapper.selectRoleIdByMenuId(menuId);
    }

    @Override
    public Integer[] existsDataByKeys(Integer... menuIds) {
        return mapper.selectByMenuIds(menuIds);
    }
}